import * as questionsApi from '@/api/hmmm/questions'

const questions = {
  namespaced: true,
  state: {
    questionsList: {},
    randomsList: {},
    choiceList: {},
    detailList: {}
  },
  mutations: {
    SET_QUESTIONS_LIST (state, newValue) {
      state.questionsList = newValue
    },
    SET_RANDOMS_LIST (state, newValue) {
      state.randomsList = newValue
    },
    SET_CHOICE_LIST (state, newValue) {
      state.choiceList = newValue
    },
    SET_DETAIL_LIST (state, newValue) {
      state.detailList = newValue
    }
  },
  actions: {
    async updataQuestionsList ({ commit }, params) {
      const res = await questionsApi.list(params)
      commit('SET_QUESTIONS_LIST', res)
    },
    async updateRandomsList ({ commit }, params) {
      const res = await questionsApi.randoms(params)
      commit('SET_RANDOMS_LIST', res)
    },
    async updateChoiceList ({ commit }, params) {
      const res = await questionsApi.choice(params)
      commit('SET_CHOICE_LIST', res)
    },
    async updateDetailList ({ commit }, params) {
      const res = await questionsApi.detail(params)
      commit('SET_DETAIL_LIST', res)
    }
  }
}

export default questions
